//
//  AuctionLogisticsTableViewCell.m
//  MyNewProject
//
//  Created by 王春辉 on 2020/1/5.
//  Copyright © 2020年 sun. All rights reserved.
//

#import "AuctionLogisticsTableViewCell.h"

@interface AuctionLogisticsTableViewCell()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *orderCodeLabel;
@end

@implementation AuctionLogisticsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = SKColorWithHex(0xF7F7F7);
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initContentViews];
    }
    return self;
}

- (void)initContentViews {
    UIView *contentView = [[UIView alloc] init];
    contentView.backgroundColor = [UIColor whiteColor];
    contentView.layer.masksToBounds = true;
    contentView.layer.cornerRadius = 4.0;
    [self addSubview:contentView];
    [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.top.mas_offset(15);
        make.bottom.mas_offset(0);
        make.right.mas_offset(-15);
    }];
    [contentView addSubview:self.titleLabel];
    [contentView addSubview:self.nameLabel];
    [contentView addSubview:self.timeLabel];
    [contentView addSubview:self.orderCodeLabel];
    UILabel *label = [[UILabel alloc] init];
    label = [[UILabel alloc] init];
    label.text = @"尊敬的用户：";
    label.font = SKFONT_Medium(12);
    label.textColor = SKColorWithHex(0xB1B1B1);
    [contentView addSubview:label];
    UIView *line1 = [[UIView alloc] init];
    line1.backgroundColor = SKColorWithHex(0xE5E5E5);
    [contentView addSubview:line1];
    
    UIView *line2 = [[UIView alloc] init];
    line2.backgroundColor = SKColorWithHex(0xE5E5E5);
    [contentView addSubview:line2];
    
    UILabel *label2 = [[UILabel alloc] init];
    label2 = [[UILabel alloc] init];
    label2.text = @"详情";
    label2.font = SKFONT_Medium(13);
    label2.textColor = SKColorWithHex(0x333333);
    [contentView addSubview:label2];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:SKIMAGE_NAMED(@"rightArrow")];
    [contentView addSubview:imageView];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(12);
        make.top.mas_offset(12);
        make.height.mas_equalTo(16);
        make.right.mas_lessThanOrEqualTo(-12);
    }];
    
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(12);
        make.right.mas_offset(-12);
        make.height.mas_equalTo(0.5);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(15);
    }];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(line1);
        make.top.mas_equalTo(line1.mas_bottom).mas_offset(14);
        make.height.mas_equalTo(13);
        make.right.mas_lessThanOrEqualTo(-12);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(line1);
        make.top.mas_equalTo(label.mas_bottom).mas_offset(10);
        make.height.mas_equalTo(13);
        make.right.mas_lessThanOrEqualTo(-12);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(line1);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).mas_offset(30);
        make.right.mas_lessThanOrEqualTo(-12);
        make.height.mas_equalTo(13);
    }];
    
    [self.orderCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(line1);
        make.top.mas_equalTo(self.timeLabel.mas_bottom).mas_offset(10);
        make.height.mas_equalTo(13);
        make.right.mas_offset(-12);
    }];

    [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.height.mas_equalTo(line1);
        make.top.mas_equalTo(self.orderCodeLabel.mas_bottom).mas_offset(14);
    }];
    
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(line1);
        make.right.mas_lessThanOrEqualTo(-60);
        make.top.mas_equalTo(line2.mas_bottom).mas_offset(15);
        make.bottom.mas_offset(-15);
    }];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(line1);
        make.centerY.mas_equalTo(label2);
    }];
    
}

#pragma mark -- mark 懒加载
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.text = @"快递发出通知";
        _titleLabel.font = SKFONT_Medium(15);
        _titleLabel.textColor = SKColorWithHex(0x333333);
    }
    return _titleLabel;
}
- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = SKColorWithHex(0xB1B1B1);
        _nameLabel.font = SKFONT_SIZE(12);
        _nameLabel.text = @"您拍卖的”商品名称”已发出，请留意。";
    }
    return _nameLabel;
}
- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.textColor = SKColorWithHex(0xB1B1B1);
        _timeLabel.font = SKFONT_SIZE(12);
        _timeLabel.text = @"寄件时间：2019-08-21 14:03:06";
    }
    return _timeLabel;
}
- (UILabel *)orderCodeLabel {
    if (!_orderCodeLabel) {
        _orderCodeLabel = [[UILabel alloc] init];
        _orderCodeLabel.textColor = SKColorWithHex(0xB1B1B1);
        _orderCodeLabel.font = SKFONT_SIZE(12);
        _orderCodeLabel.text = @"快递单号：SF123777800237";
    }
    return _orderCodeLabel;
}

#pragma mark -- mark 业务逻辑
- (void)setName:(NSString *)name {
    _name = name;
    self.nameLabel.text = [NSString stringWithFormat:@"您拍卖的”%@”已发出，请留意。", name];
}
- (void)setTime:(NSString *)time {
    _time = time;
    self.timeLabel.text = [NSString stringWithFormat:@"寄件时间：%@", time];
}
- (void)setOrderCode:(NSString *)orderCode {
    _orderCode = orderCode;
    self.orderCodeLabel.text = [NSString stringWithFormat:@"快递单号：%@", orderCode];
}
@end
